#!/bin/bash

DEST=`pwd`/build/libtag && rm -rf $DEST
SOURCE=`pwd`/taglib
ANDROID_CMAKE=`pwd`/android-cmake/android.toolchain.cmake

export NDK=/home/dev/android/ndk-r10d

TOOLCHAIN=/home/dev/android/toolchain
TOOLCHAIN64=/home/dev/android/toolchain64

#$NDK/build/tools/make-standalone-toolchain.sh --platform=android-21 --install-dir=$TOOLCHAIN --arch=arm
#$NDK/build/tools/make-standalone-toolchain.sh --platform=android-21 --install-dir=$TOOLCHAIN64 --arch=arm64
#export ANDROID_STANDALONE_TOOLCHAIN=$TOOLCHAIN
export ANDROID_STANDALONE_TOOLCHAIN=$TOOLCHAIN

cd $SOURCE
PLATFORM="armeabi"
PREFIX="$DEST/$PLATFORM" && mkdir -p $PREFIX

cmake -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE \
  -DANDROID_ABI="$PLATFORM" \
  -DBUILD_FRAMEWORK=ON \
  -DENABLE_STATIC=ON \
  -DCMAKE_INSTALL_PREFIX=$PREFIX \

make clean
make -j8
make install

cd ..
zip -r libtag.zip $DEST
mv libtag.zip /data/
